package org.ools.nools.db;

import org.ools.nools.StringUtils;

public class TableName {

	/**
	 * Format a typical DB table name (separated by underscore )to a java method name
	 * e.g.: MY_TABLE will give myTable
	 * @param name Name of the string to format
	 * @return formatted String
	 */
	public static String getAsMethodName(String name) {
		String[] underscoreSplitted = name.split("_");
		String result = underscoreSplitted[0].toLowerCase();
		for (int i = 1; i < underscoreSplitted.length; i++) {
			result += StringUtils.capitalizeFirstLetter(underscoreSplitted[i].toLowerCase());
		}
		return result;
	}
}
